#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<unistd.h>
#define myerr(m)do{perror(m);exit(EXIT_FAILURE);}while(0)
int main()
{
    int wfd = open("./myfifo",O_WRONLY);
    if(wfd < 0)
        myerr("open");
    std::string buf;
    while (1)
    {
        printf("please say: ");
        //fflush(std::out);
        std::getline(std::cin,buf);
        ssize_t wsz = write(wfd,buf.c_str(),strlen(buf.c_str()));
        if(wsz < 0)
            myerr("write");
        else if(wsz == 0)
            myerr("nothing");
        else 
            printf("write true");
    }
    close(wfd);
    return 0;
}